/*
 * AdminDeContextos.cpp
 *
 *  Created on: 19/06/2012
 *      Author: natuchis
 */

#include "AdminDeContextos.h"

AdminDeContextos::AdminDeContextos(unsigned short int ordenMax) {

	this->bloque = "";
	this->contexto = "";
	this->ptoCaracActual = 0;
	this->ordenMax = ordenMax;
}


AdminDeContextos::~AdminDeContextos() {
}


string AdminDeContextos::getContexto(unsigned short int orden) {

	if (orden > this->ordenMax) {
		orden = this->ordenMax;
	}
	return (this->contexto.substr(this->contexto.size() - orden, orden));
}


char AdminDeContextos::getCaracterActual() const {

	return (this->bloque[this->ptoCaracActual]);
}


void AdminDeContextos::nextCaracter() {

	this->agregarCaracterACtx(this->getCaracterActual());
	this->ptoCaracActual++;
}

void AdminDeContextos::setBloque(const string &bloque) {

	this->bloque = bloque;
	this->ptoCaracActual = 0;
}

void AdminDeContextos::agregarCaracterACtx(char carac) {

	this->contexto += carac;
	if (this->contexto.size() > this->ordenMax) {
		this->contexto = this->contexto.substr(1, this->ordenMax);
	}
}

unsigned short int AdminDeContextos::getOrden() const {
	return this->ordenMax;
}


